﻿namespace BM.Tools.WebControls.MForm.Example.Constraints
{
    using System;
    using System.Web.UI;
    using System.Web.UI.WebControls;

    /// <summary>
    /// </summary>
    public partial class CustomConstraint : Page
    {
        /// <summary>
        /// </summary>
        /// <param name="source">
        /// The source.
        /// </param>
        /// <param name="args">
        /// The args.
        /// </param>
        protected void EvenOnlyValidate(object source, ServerValidateEventArgs args)
        {
            try
            {
                int value = Convert.ToInt32(args.Value);
                args.IsValid = value % 2 == 0;
            } 
            catch
            {
                args.IsValid = false;
            }
        }

        /// <summary>
        /// </summary>
        /// <param name="sender">
        /// The sender.
        /// </param>
        /// <param name="e">
        /// The e.
        /// </param>
        protected void Page_Load(object sender, EventArgs e)
        {
            Root1.NotifyToolbox();
        }
    }
}